#include <iostream>
#include <vector>
#include <Vector.hpp>
using namespace std;

class Solution
{
public:
    vector<int> productExceptSelf(vector<int> &nums)
    {
        vector<int> results(nums.size());
        results[0] = 1;
        int backMulti = nums[nums.size() - 1];
        for (int i = 1; i < nums.size(); i++)
        {
            results[i] = results[i - 1] * nums[i - 1];
        }
        for (int i = nums.size() - 2; i >= 0; i--)
        {
            results[i] *= backMulti;
            backMulti *= nums[i];
        }
        return results;
    }
};

int main()
{
    cout << "Code238" << endl;
    Solution s;
    vector<int> nums{1, 2};
    PrintVector(s.productExceptSelf(nums));
    return 0;
}